function ApplicationWindow() {
	//declare module dependencies
	var MasterView = require('ui/common/MasterView'),
		DetailView = require('ui/common/DetailView'),
		BookmarkView = require('ui/common/BookmarkView'),
		YoutubeView = require('ui/common/YoutubeWebView');
		
	//create object instance
	var self = Ti.UI.createWindow({
		backgroundColor:'#ffffff'
	});
		
	//construct UI
	var masterView = new MasterView(),
		detailView = new DetailView(),
		bookmarkView = new BookmarkView(),
		youtubeView = new YoutubeView();
		
	//create master view container
	var masterContainerWindow = Ti.UI.createWindow({
		title:'Songs',
		barColor : '#000000'
	});
	masterContainerWindow.add(masterView);
	
	var bookmarkContainerWindow = Ti.UI.createWindow({
		title:'Bookmarks',
		barColor : '#000000'
	});
	bookmarkContainerWindow.add(bookmarkView);
	
	//create detail view container
	var detailContainerWindow = Ti.UI.createWindow({
		barColor : '#000000'
	});
	detailContainerWindow.add(detailView);
	
	var youtubeContainerWindow = Ti.UI.createWindow({
		barColor : '#000000',
		title: 'Search YouTube'
	});
	youtubeContainerWindow.add(youtubeView);
	
	//create iOS specific NavGroup UI
	var navGroup = Ti.UI.iPhone.createNavigationGroup({
		window:masterContainerWindow
	});
	self.add(navGroup);
	
	var langButton = Ti.UI.createButton({
		title:'ENG'
	});
	
	var tableLangButton = Ti.UI.createButton({
		title:'ENG'
	});
	
	var bookmarkLangButton = Ti.UI.createButton({
		title:'ENG'
	});
	
	//add behavior for master view
	masterView.addEventListener('itemSelected', function(e) {
		e.langButton = langButton;
		if(tableLangButton.title == "ENG") {
			e.lang = "mal";
		}
		else {
			e.lang = "eng";
		}
		e.showBookmarkIcon = true;
		detailView.showShare(true);
		detailView.fireEvent('itemSelected',e);
		detailContainerWindow.title = e.title_ml;
		navGroup.open(detailContainerWindow);
	});
	
	bookmarkView.addEventListener('itemSelected', function(e) {
		e.langButton = langButton;
		if(bookmarkLangButton.title == "ENG") {
			e.lang = "mal";
		}
		else {
			e.lang = "eng";
		}
		e.showBookmarkIcon = false;
		detailView.showShare(true);
		detailView.fireEvent('itemSelected',e);
		detailContainerWindow.title = e.title_ml;
		navGroup.open(detailContainerWindow);
	});
	
	langButton.addEventListener('click',function(e) {
		e.langButton = langButton;
		detailView.fireEvent('langClicked', e);
	});
	
	tableLangButton.addEventListener('click',function(e) {
		e.langButton = tableLangButton;
		masterView.fireEvent('langClicked', e);
	});
	
	bookmarkLangButton.addEventListener('click',function(e) {
		e.langButton = bookmarkLangButton;
		bookmarkView.fireEvent('langClicked', e);
	});
	
	masterContainerWindow.setRightNavButton(tableLangButton);
	bookmarkContainerWindow.setRightNavButton(bookmarkLangButton);
	
	var infoButton = Ti.UI.createButton({
		systemButton : Titanium.UI.iPhone.SystemButton.INFO_LIGHT
	});
	masterContainerWindow.setLeftNavButton(infoButton);	
	
	infoButton.addEventListener('click', function(e) {
		e.langButton = langButton;
		e.title_ml = 'About';
		e.title_en = 'About';
		e.ml = "about.html";
		e.lang = 'ml';
		e.showBookmarkIcon = false;
		detailView.showShare(false);
		detailView.fireEvent('itemSelected', e);
		detailContainerWindow.title = "About";
		navGroup.open(detailContainerWindow);
	});
	
	masterView.addEventListener('showBookmarks', function(e) {
		bookmarkView.reloadData();
		navGroup.open(bookmarkContainerWindow);
	});
	
	detailView.addEventListener('youtubeClicked', function(e) {
		youtubeView.searchYoutube({url: e.title_en});
		youtubeContainerWindow.open();
	});
	
	youtubeView.addEventListener('youtubeWindowClosed', function(e) {
		youtubeContainerWindow.close();
	});
	
	return self;
};

module.exports = ApplicationWindow;
